package com.webtest.jsptest;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/7/24 15:13
 */
public class TestAttr extends HttpServlet {
    private static final long serialVersionUID = 609610328745143122L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();
        // request
        Object requestAttr = req.getAttribute("requestAttr");
        out.println("requestAttr:" + requestAttr);
        out.println("<br><br>");
        // session
        Object sessionAttr = req.getSession().getAttribute("sessionAttr");
        out.println("sessionAttr:" + sessionAttr);
        out.println("<br><br>");
        // application
        Object applicationAttr = getServletContext().getAttribute("applicationAttr");
        out.println("applicationAttr:" + applicationAttr);
    }
}
